/**
 * arr数组按type升序排列
 * @param {Array} arr
 * @param {string} key
 */
export const riseSort = (arr, key) => {
  arr.sort((val1, val2) => {
    return val1[key] - val2[key];
  });
};

/**
 * 数组冒泡排序
 * @param {Array} arr
 * @returns
 */
export const bubbleSort = (arr) => {
  for (var i = 1; i < arr.length; i++) {
    for (var j = 0; j < arr.length - i; j++) {
      if (arr[j] > arr[j + 1]) {
        var t = arr[j];
        arr[j] = arr[j + 1];
        arr[j + 1] = t;
      }
    }
  }
  return arr;
};
